<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/page/inc/taglib.jsp"%>
<div class="pageContent">
	<form method="post" id="form" action="${pageContext.request.contextPath}${requestScope.record ==null ?'/merchant/merchantProductNorm/insert' :'/merchant/merchantProductNorm/update' }" class="pageForm required-validate">
		<div class="pageFormContent" layoutH="56">
			<!-- 关闭窗口 -->
			<input type="hidden" name="callbackType" value="closeCurrent" />
			<!-- 隐藏表单 -->
			<c:if test="${requestScope.record !=null}">
				<input type="hidden" name="merchantProductNormId" value="${requestScope.record.merchantProductNormId}" />
				<%-- <input type="hidden" name="merchantProductId" value="${requestScope.record.merchantProductId}" />
				<input type="hidden" name="addTime"  value="<fmt:formatDate pattern="yyyy-MM-dd" value="${requestScope.record.addTime}" />" />
				<input type="hidden" name="operator" value="${requestScope.record.operator}" />
				<input type="hidden" name="del" value="${requestScope.record.del}" /> 
				<input type="hidden" name="normPicUrl" value="${requestScope.record.normPicUrl}" /> --%>
			</c:if>
			<c:if test="${requestScope.record ==null}">
				<input type="hidden" name="merchantProductId" value="${requestScope.productid}" />
			</c:if>
			<p>
				<label>规格名称</label> <input name="normName" class="required" maxlength="50" type="text" value="${requestScope.record.normName}" />
			</p>
			<p>
				<label>商品编号</label> <input name="productNum" class="required" maxlength="11" type="text" value="${requestScope.record.productNum}" />
			</p>
			<p>
				<label>进货价格</label> <input id="primeCostsPrice" class="required number" maxlength="11" type="text" value="${requestScope.record.primeCostsPrice*0.01}" />
			</p>
			<p>
				<label>建议售卖价格</label> <input id="suggestedPrice" class="required number" maxlength="11" type="text" value="${requestScope.record.suggestedPrice*0.01}" />
			</p>

			<p>
				<label>产地</label> <input name="place" class="required" maxlength="50" type="text" value="${requestScope.record.place}" />
			</p>
			<p>
				<label>等级</label> <input name="level" class="required" maxlength="50" type="text" value="${requestScope.record.level}" />
			</p>
			<p>
				<label>容量</label> <input name="capacity" class="required" maxlength="50" type="text" value="${requestScope.record.capacity}" />
			</p>
			<p>
				<label>装箱率</label> <input name="pack" class="required" maxlength="50" type="text" value="${requestScope.record.pack}" />
			</p>
			<p>
				<label>加盟价</label> <input id="fcpc" class="required number" maxlength="11" type="text" value="${requestScope.record.fcpc}" />
			</p>
			<p>
				<label>葡萄品种</label> <input name="gpvt" class="required" maxlength="50" type="text" value="${requestScope.record.gpvt}" />
			</p>
			<p>
				<label>最佳饮用温度</label> <input name="odpt" class="required" maxlength="50" type="text" value="${requestScope.record.odpt}" />
			</p>
			<p>
				<label>酒评</label> <input name="wirv" class="required" maxlength="50" type="text" value="${requestScope.record.wirv}" />
			</p>
			<p>
				<label>佐餐建议</label> <input name="mrcm" class="required" maxlength="50" type="text" value="${requestScope.record.mrcm}" />
			</p>
			<p>
				<label>醒酒时间</label> <input name="sbtm" class="required" maxlength="50" type="text" value="${requestScope.record.sbtm}" />
			</p>

			<p>
				<label>排序</label> <input name="sorting" class="required" maxlength="11" type="text" value="${requestScope.record.sorting}" />
			</p>
		</div>
		<div class="formBar">
			<ul>
				<li><div class="buttonActive">
						<div class="buttonContent">
							<button type="submit">保存</button>
						</div>
					</div></li>
				<li>
					<div class="button">
						<div class="buttonContent">
							<button type="button" class="close">取消</button>
						</div>
					</div>
				</li>
			</ul>
		</div>
	</form>
</div>
<script type="text/javascript">
	//监听form表单提交事件并且重写
	$("#form", $.pdialog.getCurrent()).submit(function() {
		format();
		return validateCallback(this, dialogAjaxDone);
	})
	function format() {
		$(".number").each(function() {
			var name = $(this).attr("id");
			var val = $(this).val();
			$("#form", $.pdialog.getCurrent()).append("<input type='hidden' name='" + name + "' value='" + numMulti(val, 100) + "' />");
		});
	}
	/**
	 * 乘法运算，避免数据相乘小数点后产生多位数和计算精度损失。
	 *
	 * @param num1被乘数 | num2乘数
	 */
	function numMulti(num1, num2) {
		var baseNum = 0;
		try {
			baseNum += num1.toString().split(".")[1].length;
		} catch (e) {
		}
		try {
			baseNum += num2.toString().split(".")[1].length;
		} catch (e) {
		}
		return Number(num1.toString().replace(".", "")) * Number(num2.toString().replace(".", "")) / Math.pow(10, baseNum);
	};
</script>